//
//  HPSmsCell.m
//  HappyPenguin
//
//  Created by zhuangyihang on 1/30/16.
//  Copyright © 2016 zhuangyihang. All rights reserved.
//

#import "HPSmsCell.h"
#import "NSString+Common.h"
#import "UIConstants.h"

static NSInteger kFontSize = 16;
static NSInteger kViewMargin = 15;

@interface HPSmsCell()

@property (nonatomic, strong) UILabel *contentLabel;

@end

@implementation HPSmsCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.contentLabel = [UILabel new];
        [self.contentView addSubview:self.contentLabel];
        self.contentLabel.numberOfLines = 0;
        self.contentLabel.textColor = [UIColor colorWithRGB:0x737373];
        self.contentLabel.font = [UIConstants getFont:kFontSize];
        [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.height.equalTo(self.contentView).offset(-2*kViewMargin);
            make.center.equalTo(self.contentView);
        }];
        
    }
    return self;
}

+ (CGFloat)getCellHeight:(NSString *)content{
    CGFloat height = 0;
    
    CGFloat screenWidth = [[UIScreen mainScreen] bounds].size.width;
    
    CGFloat width = screenWidth - 2* kViewMargin;
    
    height = [content getHeightWithWidth:width withFont:[UIConstants getFont:kFontSize]];
    
    height += 2 * kViewMargin;
    
    height += 5;
    
    return height;
}

- (void)setup:(NSString *)content{
    self.contentLabel.text = content;
}

@end
